<template id="doudle_air_complete">
	<div class="doudle_air_complete">
	
	
	
		
		<div class="doudle_main" v-for="(item,index) in todos" :key="index">
		
		  <div class="doudle_main_top"><img src="../../assets/images/my_order/my_order_15.png"/>
		  <img src="../../assets/images/main/doudle_del.png" @click="total(item.bookingid)"/></div>
		  <div class="doudle_main_dl">
		  	<div class="doudle_dl">
		  		<dl>
		  		   
		  			<dt><img v-lazy="item.photo"/></dt>
		  			<dd>
		  				<p>{{item.coach_name}}</p>
							<p>{{item.class_name}}</p>
							<p>预约时间:{{item.create_time | formatDate}}</p>
		  			</dd>
		  			
		  		</dl>
		  	</div>
		  </div>
		  
		  <div class="doudle_money">
		  	<div class="doudle_neth">
		  		<span>应付款: </span><font>￥{{item.price}}</font>
		  	</div>
		  </div>
		  
		   <div class="doudle_detail">
		  	<div class="doudle_hear">
		  		<router-link :to="{path:'/order_details',query:{bookingid:item.booking_id}}"><button>查看订单</button></router-link>
		  	
		  	</div>
		  </div>
			
			
		</div>
		
		
		
	</div>
</template>

<script>export default {
	data() {

		return {
			seen: true,
			todos: [],
			bookingid: '',
			price: '',
			create_time: '',
			yuan: ''
		}

	},
	components: {},
	created() {

		//let SESSION_ID = JSON.parse(window.sessionStorage.getItem('SESSION_ID'));
		var SESSION_ID = JSON.parse(window.localStorage.getItem('sessiond'))
		let obj = {
			//请求的参数
			userid: SESSION_ID.user.id,
			sessionid: SESSION_ID.sessionid,

		};
		let _this = this
		let qs = require('qs');
		this.$axios.post("/yujia/user/findUnfinishedBookingByUserId", qs.stringify(obj), {
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
			//重写headers 请求头  qs.stringify(json对象) 把对象转化为字符串 
		}).then(function(response) {
			_this.todos = response.data.data;
			_this.bookingid = response.data.data[0].booking_id
			console.log(_this.bookingid)
		}).catch(function(error) {
			console.log(error);
		});

	},
	filters: {
		formatDate: function(value) {
			let date = new Date(value);
			let y = date.getFullYear();
			let MM = date.getMonth() + 1;
			MM = MM < 10 ? ('0' + MM) : MM;
			let d = date.getDate();
			d = d < 10 ? ('0' + d) : d;
			let h = date.getHours();
			h = h < 10 ? ('0' + h) : h;
			let m = date.getMinutes();
			m = m < 10 ? ('0' + m) : m;
			let s = date.getSeconds();
			s = s < 10 ? ('0' + s) : s;
			return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
		},
	},
	methods: {
		total(bookingid) {
			let _this = this
			//let SESSION_ID = JSON.parse(window.sessionStorage.getItem('SESSION_ID'));
			var SESSION_ID = JSON.parse(window.localStorage.getItem('sessiond'))
			let obj = {
				//请求的参数
				sessionid: SESSION_ID.sessionid,
				userid: SESSION_ID.user.id,
				bookingid: _this.bookingid
			};
			let qs = require('qs');
			_this.$axios.post("/yujia/booking/cancelBookingIfPay", qs.stringify(obj), {
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
				//重写headers 请求头  qs.stringify(json对象) 把对象转化为字符串
			}).then(function(response) {
				console.log(response.data.data)
				if(response.data.code == '1') {
					mui.alert('取消成功')
					window.location.reload();
				} else if(response.data.code == '-4'){
					// _this.seen=false
					mui.alert(response.data.message)

				}else if(response.data.code == '-2'){
					mui.alert(response.data.message)
				}
			}).catch(function(error) {
				console.log(error);
			});
		}
	},

	computed: {

	}

}</script>

<style scoped>
	@import "../../assets/css/doudle_air_complete.css";

</style>
